package com.itheima.day816.demo03;

public class Demo1 {
    /*
    fina1修饰成员变量!特点:
    1.被fina 1修饰的成员变量一旦初始化,其值不可变!
    2.被fina 1修饰的成员变量只能赋值一次,但是赋值时机有两种:
    2.1可以在定义类时，直接给值.后期该类所有对象该属性值固定不可变!(全类所有对象公用同一个值!)
    2.2在定义时不给值,在所有构造方法执行结束前对其赋值!(一-个对象-个值, 后期不可变)
     */
    public static void main(String[] args) {
        YellowFamily y = new YellowFamily();
        //姓不可变
        System.out.println(y.XING);
        //性别不可变
        System.out.println(y.sex);
        YellowFamily y1 = new YellowFamily("女");
        System.out.println(y.XING);
        System.out.println(y1.sex);
    }
}

class YellowFamily {
    final String XING = "黄";
    final String sex;

    public YellowFamily() {
        sex = "男";
    }

    public YellowFamily(String sex) {
        this.sex = sex;
    }
}
